home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7050 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: alpha.sky.net!DMPR
  2. From: robertson@acm.org (Marc Robertson)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: STL
  5. Date: Wed, 21 Feb 96 15:19:48 GMT
  6. Organization: SkyNET Online
  7. Message-ID: <4gfdan$81f@alpha.sky.net>
  8. References: <4gdgt0$494@netaxs.com>
  9. NNTP-Posting-Host: ip104.sky.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <4gdgt0$494@netaxs.com>, bobpez@netaxs.com (Bob Pesavento) wrote:
  13. >I'm a newbie with STL and not an expert at C++ so bear with me.  Assume a 
  14. >simplified class:
  15. >
  16. >class myclass
  17. >{
  18. >  int myint;
  19. >  float myfloat;
  20. >
  21. >  public:
  22. >
  23. > (the usual... constructors etc)
  24. >};
  25. >
  26. >I want use "list" and stuff a bunch of these in using push_back.  No 
  27. >problem so far.  But I want the user to be able to select which item to 
  28. >sort on... myint or myfloat.  What I have seen is that I can only set up 
  29. >for one using the operator < and operator ==.  I don't want multiple 
  30. >lists.  Can anyone give me an idea how to do this?  Your help will be 
  31. >appreciated.
  32. >
  33. >my e-mail addresses are:
  34. >bobpez@netaxs.com  or  Bob@chiinc.com
  35. >
  36. I'm pretty new at this also, but it looks to me that if you could
  37. use a deque or vector, you would be able to use the version of the
  38. sort algorithm that takes 2 random access iterators and a function
  39. object that does the compare.  Then, you could pass in whatever 
  40. function object you needed, to do the compare selected by the user.
  41.  
  42. Marc Robertson
  43.